import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router';
import { routes } from './router.config';
import NProgress from 'nprogress'; // 引入进度条插件
import 'nprogress/nprogress.css'; // 引入对应css样式

const router = createRouter({
  history: createWebHistory(),
  routes: routes,
});

// 路由守卫
router.beforeEach((to, from, next) => {
  // 开启页面进度条
  NProgress.start();
  next();
});

router.afterEach(() => {
  NProgress.done();
});

export default router;
